package com.haozi.ehub.core.util;

import com.haozi.ehub.entity.code.EncryptCode;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * MD5加密帮助类，由于业务原因暂停使用
 * @author ：terry
 * @date ：Created in 2020/6/16 14:45
 * @version: 1.0
 */
@Deprecated
public class Md5Utils {
    /**
     * md5加密
     * @author     ： terry
     * @date       ： Created in 2020/6/16 15:18
     * @param: password 加密字符串
     * @return： String
     */
    public static String encode(String arg){
        StringBuilder stringBuilder = new StringBuilder();
        MessageDigest digest = null;
        try {
            digest = MessageDigest.getInstance(EncryptCode.MD5);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        byte[] argSalt = (arg + EncryptCode.MD5_SALT_.hashCode()).getBytes();
        assert digest != null;
        byte[] result = digest.digest(argSalt);
        for (byte b : result) {
            String s=Integer.toHexString(0xff & b);
            stringBuilder.append(s);

        }
        return stringBuilder.toString();
    }
}
